<?php

if ($_REQUEST['action'] = "list")
{
	if ($db = new SQLiteDatabase('InstantInput.db')) 
	{
		$result = $db->query("SELECT * FROM Classes WHERE class_id='". $REQUEST['class_id']  ."'");	
		print json_encode($result->fetchAll());
	} 
	else 
	{
	    die($err);
	}
}

if ($_REQUEST['action'] = "add_class")
{
	if ($db = new SQLiteDatabase('InstantInput.db')) 
	{
		$command = "Insert INTO User_Classes (class_code, class_name, teacher) VALUES (" . $REQUEST['class_code'] . ", " . $REQUEST["class_name"] . ", " . $REQUEST["teacher"] . ")";	
		$db->queryExec($command);
	} 
	else 
	{
	    die($err);
	}
}	

?>